Methods of facilitating packet-based connections

ABSTRACT

Methods of facilitating communication between clients and servers are contemplated. Embodiments of the inventive subject matter make it possible for a client to establish a packet-based connection with a server by first authenticating with a web backend. This can enable, for example, a client to establish a packet-based connection with a server though a web browser.

This application is a divisional of and claims priority to U.S. patentapplication Ser. No. 15/656,454 filed on Jul. 21, 2017 and U.S.provisional patent application Ser. No. 62/462,224 entitled “Methods ofImplementing UDP in Web Browsers,” filed on Feb. 22, 2017.

FIELD OF THE INVENTION

The field of the invention is web browser technology.

BACKGROUND

The background description includes information that may be useful inunderstanding the present invention. It is not an admission that any ofthe information provided in this application is prior art or relevant tothe presently claimed invention, or that any publication specifically orimplicitly referenced is prior art.

Web browsers are built on top of HTTP, which is a statelessrequest/response protocol initially designed for serving static webpages. HTTP is built on top of TCP, a low-level protocol whichguarantees data sent over the internet arrives reliably, and in the sameorder it was sent.

TCP is a reliable-ordered protocol, which means packets of data must beinterpreted in the correct order. To deliver data reliably (and inorder) while experiencing packet loss, it is necessary for TCP to holdmore recent data in a queue while waiting for dropped packets to beresent. Otherwise, data would be delivered out of order. This is called“head of line blocking,” and it creates problems for game developers whosend time-series data such as player inputs and the state of objects ina game world. When time series data is sent over TCP, the most recentdata is delayed while waiting for old data to be retransmitted. By thetime the retransmitted data arrives, it is too old to be used.

HTTP has functioned well for many years, but recently websites havebecome more interactive and poorly suited to the HTTP request/responseparadigm. Some have attempted to address these shortcomings with modernweb protocols like WebSockets (a computer communications protocol thatprovides full-duplex communication channels over a single TCPconnection), WebRTC (a free, open project that enables web browsers withReal-Time Communications (RTC) capabilities via simple JavaScript APIs),HTTP 2.0 (an improved HTTP protocol designed to decrease latency toimprove page load speed in web browsers), and QUIC (a protocol similarto TCP+TLS+HTTP/2 except it is implemented on UDP).

WebSockets are an extension to the HTTP protocol, which enablesbidirectional data exchange—an improvement over the traditionalrequest/response pattern. Although bidirectional data exchange is a stepin the right direction, WebSockets are implemented on top of TCP, anddata is still subject to head of line blocking.

QUIC is an experimental protocol that supports multiple data streams,and it is built on top of UDP. QUIC is designed as replacement transportlayer for HTTP. New data streams can be created implicitly by the clientor server by increasing the channel ID. The channel concept implementedby QUIC has two key benefits: it avoids a connection handshake each timea new request is made, and it eliminates head of line blocking betweenunrelated data streams. But while head of line blocking is eliminatedacross unrelated data streams, it persists within each individualstream.

WebRTC is a collection of protocols that enable peer-to-peercommunication between browsers for applications like audio and videostreaming. WebRTC supports a data channel that can be configured inunreliable mode, providing a way to send and receiveunreliable-unordered data from the browser. WebRTC includes STUN, ICE,and TURN support. STUN, ICE, and TURN are IETF standard protocols fornegotiating traversing NATs when establishing peer-to-peer communicationsessions. But within the game development community, there exists atrend away from peer-to-peer communication towards client/servercommunication for multiplayer games, and while WebRTC supportsunreliable-unordered peer-to-peer data exchanged between browsers, it isdifficult to use WebRTC in a client/server context.

Another solution to consider is to allow users send and receive UDPpackets directly from the browser. This fails for several reasons. (1)Websites would be able to launch DDoS attacks by coordinating UDP packetfloods from browsers. (2) New security holes would be created asJavaScript running in web pages could craft malicious UDP packets toprobe the internals of corporate networks and report back over HTTPS.(3) UDP packets are not encrypted, so any data sent over these packetscould be sniffed and read by an attacker, or even modified duringtransmission. And (4), there is no authentication, so a dedicated serverreading packets sent from a browser would have to implement its ownmethod to ensure that only valid clients can connect to it. Therefore,allowing JavaScript to create UDP sockets in the browser is anonstarter.

At worst these new standards for web development do not provide adequatetechnological infrastructure to meet multiplayer game's needs, and, atbest, they provide it in a form that is too complicated for gamedevelopers to use. Thus, there is still a need for a protocol thatimplements the ability to send and receive UDP packets in the browser.

These and all other extrinsic materials discussed in this applicationare incorporated by reference in their entirety. Where a definition oruse of a term in an incorporated reference is inconsistent or contraryto the definition of that term provided in this application, thedefinition of that term provided in this application applies and thedefinition of that term in the reference does not apply.

SUMMARY OF INVENTION

In one aspect of the inventive subject matter, a method of establishinga network connection between a client and a dedicated server tofacilitate multiplayer gaming is contemplated. It is also contemplatedthat only authenticated clients may connect to a server, and packetsexchanged between the client and server are encrypted and signed, sothat they may not be read by third parties or modified in transit.

In some embodiments, the client is a traditional game client running inits own executable (e.g., a AAA game running on PC, Xbox orPlayStation). In other embodiments, a game client runs inside a webbrowser for browser based gaming.

The client authenticates with a web backend, using for example OAuth2.0. Once authenticated, the game client sends a request to play to theweb backend. The web backend determines a set of dedicated serverssuitable for the client to connect to, and returns these to the clientin the form of a connect token.

Connect tokens are short-lived cryptographic tokens that transfer clientauthentication with the web backend to the client connection to theserver. In some embodiments, a server only allows connection clientswith a valid connect token that has not expired, and has not alreadybeen used on that server. This ensures that clients must authenticatewith the web backend and obtain a connect token in order to connect to aserver.

In some embodiments, the connect token includes both public data (e.g.,encryption keys for packets and an array of server addresses) andprivate data, where the private data is encrypted and signed viasymmetric encryption using a shared private key, and portions of thepublic data are signed by the shared private key.

In other embodiments, the connect token includes both public data (e.g.,encryption keys for packets and an array of server addresses) andprivate data. The private data can be encrypted and signed viaasymmetric encryption using the private key of the web backend and thepublic key of the server, and portions of the public data are signed andencrypted by the private key of the web backend and the public key ofthe client.

In some embodiments, the client reads the connect token public data anduses this information to attempt connection to each server in turn,accepting connection with the first server that allows the client toconnect.

Connection to a server is initiated by the client sending connectionrequest packets to the server containing portions of the private andpublic connect token over an unreliable, packet-based network protocol,for example, UDP.

The server upon receiving a connection request packet ignores anyconnection requests that do not include a valid connect token, or thatcontain a connect token which has expired, or has already been used onthat server.

A challenge-response protocol is implemented to disallow clients withspoofed IP addresses from connecting to the server. When receiving aconnection request from a client, instead of immediately granting thatclient connection with the server, a connection challenge packet is sentto the client which includes a challenge token.

The challenge token includes data relevant to the network connection,and it is encrypted and signed with a random key that is generated whenthe server is started.

The client is only allowed to complete connection to the server onlywhen it returns a challenge response packet to the server, containingthe challenge token data from the connection challenge packet, provingthat the client is able to receive data sent to the IP source address ofits packets. The challenge response packet is intentionally smaller thanthe connection request packet, so the challenge-response protocol maynot be used as part of a DDoS amplification attack.

In some embodiments, the client connection slot on the server entersinto a connected but unconfirmed state after receiving a challengeresponse packet from the client, allowing the server to send connectionpayload packets to the client earlier than if it waited for theconnection to be fully established.

Once a connection is established between a client and server, the clientand server exchange can connection payload packets in both directions.In some embodiments, these packets are encrypted and signed withsymmetric encryption using private keys included in the connect tokenprivate data.

BRIEF DESCRIPTIONS OF THE FIGURES

FIG. 1 shows a client authenticating with a web backend.

FIG. 2 shows a client communicating with a web backend afterauthenticating.

FIG. 3 shows a connect token.

FIG. 4 shows a client attempting to connect with several servers.

FIG. 5 shows different steps associated with establishing a connectingwith a server.

FIG. 6 shows a server sending a connection keep-alive packet and aconnection payload packet to a client.

FIG. 7 shows a server sending a connection payload packet to a client.

FIG. 8a illustrates a disconnection technique.

FIG. 8b shows another disconnection technique.

FIG. 9 shows a challenge token.

FIG. 10 shows a connection request packet.

FIG. 11 illustrates a method of reading an encrypted packet.

FIG. 12 illustrates a method of replay protection.

FIG. 13 illustrates a method of verifying connect token validity.

FIG. 14 illustrates how a client can behave when it receives aconnection request denied packet while in the sending connection requeststate.

FIG. 15 illustrates how a client can behave when it receives neither aconnection challenge packet nor a connection denied packet within thetimeout period specified in a connect token.

FIG. 16 is a flowchart showing how a connection request packet ishandled.

FIG. 17 is a flowchart showing how server slot availability is handled.

FIG. 18 is a flowchart showing how a connection response packet ishandled.

DETAILED DESCRIPTION

The present invention relates to a network communication protocol. Inone aspect of the inventive subject matter, a method of facilitatingcommunication between a client and a server is contemplated. The methodincludes the steps of: establishing a connection between the client andthe server, and encrypting and signing packets of data to be set overthe connection. The method includes the additional step ofauthenticating the client (e.g., prior to establishing the connection).

At its core, a method of the inventive subject matter includes thefollowing properties: it is connection-based, so it could not be used inDDoS attacks or to probe security holes; data transmissions areencrypted and signed so packets cannot be read or modified in transit;and it implements authentication so dedicated servers only acceptconnections from clients who are authenticated on the web backend.

The following discussion provides example embodiments of the inventivesubject matter. Although each embodiment represents a single combinationof inventive elements, the inventive subject matter is considered toinclude all possible combinations of the disclosed elements. Thus, ifone embodiment comprises elements A, B, and C, and a second embodimentcomprises elements B and D, then the inventive subject matter is alsoconsidered to include other remaining combinations of A, B, C, or D,even if not explicitly disclosed.

As used in the description in this application and throughout the claimsthat follow, the meaning of “a,” “an,” and “the” includes pluralreference unless the context clearly dictates otherwise. Also, as usedin the description in this application, the meaning of “in” includes“in” and “on” unless the context clearly dictates otherwise.

In some embodiments, the numbers expressing quantities of ingredients,properties such as concentration, reaction conditions, and so forth,used to describe and claim certain embodiments of the invention are tobe understood as being modified in some instances by the term “about.”Accordingly, in some embodiments, the numerical parameters set forth inthe written description and attached claims are approximations that canvary depending upon the desired properties sought to be obtained by aparticular embodiment. In some embodiments, the numerical parametersshould be construed considering the number of reported significantdigits and by applying ordinary rounding techniques. Notwithstandingthat the numerical ranges and parameters setting forth the broad scopeof some embodiments of the invention are approximations, the numericalvalues set forth in the specific examples are reported as precisely aspracticable. The numerical values presented in some embodiments of theinvention may contain certain errors necessarily resulting from thestandard deviation found in their respective testing measurements.Moreover, and unless the context dictates the contrary, all ranges setforth in this application should be interpreted as being inclusive oftheir endpoints and open-ended ranges should be interpreted to includeonly commercially practical values. Similarly, all lists of valuesshould be considered as inclusive of intermediate values unless thecontext indicates the contrary.

Any language directed to a computer should be read to include anysuitable combination of computing devices, including servers,interfaces, systems, databases, agents, peers, engines, controllers, orother types of computing devices operating individually or collectively.One should appreciate the computing devices comprise a processorconfigured to execute software instructions stored on a tangible,non-transitory computer readable storage medium (e.g., hard drive, solidstate drive, RAM, flash, ROM, etc.). The software instructionspreferably configure the computing device to provide the roles,responsibilities, or other functionality as discussed below with respectto the disclosed apparatus. In especially preferred embodiments, thevarious servers, systems, databases, or interfaces exchange data usingstandardized protocols or algorithms, possibly based on HTTP, HTTPS,AES, public-private key exchanges, web service APIs, known financialtransaction protocols, or other electronic information exchangingmethods. Data exchanges preferably are conducted over a packet-switchednetwork, the Internet, LAN, WAN, VPN, or other type of packet switchednetwork. The following description includes information that may beuseful in understanding the present invention. It is not an admissionthat any of the information provided in this application is prior art orrelevant to the presently claimed invention, or that any publicationspecifically or implicitly referenced is prior art.

A network protocol is contemplated that allows clients to securelyconnect to dedicated servers and communicate over UDP. The contemplatednetwork protocol is connection oriented, and it encrypts and signspackets. It provides authentication support so that only authenticatedclients can connect to dedicated servers. It is designed so that, forexample, web-based games implemented using the network protocol canshunt players from a website to one or more dedicated server instances,each with some maximum number of players (e.g., up to 256 players).

In some embodiments of the inventive subject matter, a web backendperforms authentication. When a client wants to, for example, play agame, that client will make a REST call to the web backend requesting aconnect token. The web backend returns a connect token to the clientover a secure channel (such as HTTPS, since the connect token containspublic data that should not be vulnerable to inspection by unauthorizedparties). The connect token is then used as a part of the UDP connectionhandshake between the client and the dedicated server.

Connect tokens are short lived and rely on a shared private key betweenthe web backend and dedicated server instances. A benefit of theapproach described in this application is that only authenticatedclients can connect to dedicated servers. By focusing on dedicatedservers, the need for ICE, STUN, and TURN is obviated. By implementingencryption, signing, and authentication with, for example, libsodium (alibrary for encryption, decryption, signatures, password hashing, andmore), the complexity of a full implementation of Datagram TransportLayer Security (DTLS) is avoided, while still providing the same levelof security.

In some embodiments of the inventive subject matter, a client firstauthenticates with a web backend using standard authenticationtechniques (e.g., OAuth or OAuth 2.0). This is demonstrated visually inFIG. 1. Once a client is authenticated, they can make a REST call to,for example, play a game. The REST call returns a connect token (e.g., abase64 encoded connect token) to that client over a secure encryptedchannel, for example HTTPS, as seen in FIG. 2.

A connect token (shown in FIG. 3) of the inventive subject matter hastwo parts: (1) private data, encrypted and signed by the shared privatekey using an Authenticated Encryption with Associated Data (AEAD)primitive form, for example, libsodium that cannot be read, modified, orforged by the client; and (2) public data, that provides information theclient needs to connect to a server (e.g., encryption keys for UDPpackets and the list of server addresses to connect to, along with someother information corresponding to the ‘associated data’ portion of theAEAD). Because the connect token contains public data (which is notencrypted), it is necessary for it to be communicated to the client overa secure channel, such as HTTPS.

In some embodiments, instead of a connect token including a list ofserver addresses, an individual connect token is generated for eachserver that the client can connect to, in turn. In this situation, eachindividual connect token is encrypted such that only the server that itwas generated for can read it through implementation of asymmetriccryptography. In other words, each server has a private key/public keypair, and the connect tokens generated for each server contain privatedata that is encrypted using the private key of the web backend and thepublic key of the server, and may be decrypted using the public key ofthe web backend and the private key of the server.

The web backend is, for example, a web server, that a client (e.g., apersonal computer or other network enabled computing device) cancommunicate with via REST calls over HTTPS. The client can communicateusing, for example, a browser, a game, or other software capable ofnetwork communication. The job of the web backend is to authenticate theuser (e.g., sign the user in or verify the user's identity). Once a useris authenticated, for example, the web backend knows the identity of theuser (e.g., the user is authenticated and associated with a 64-bit ID).With authentication completed by the web backend, a connect token isused to create a cryptographically secure way to transfer theauthenticated session from the web backend to, for example, a dedicatedserver instance.

In the context of a game, for example, there could exist a web backendwhere all players (e.g., clients) sign in (e.g., are authenticated), andthen afterwards request to play the game. In response to anauthenticated client requesting to play, the web backend can thendetermine which dedicated servers have free slots and can applyadditional logic (e.g., sending players to servers running the game modethe player requested or the version of the game that matches thatclient, etc.). The web backend gives a connect token back to the client.The token instructs the client to attempt to connect to a set of servers(e.g., server IP addresses) in a specific order and to connect to thefirst server that allows for the connection to be completed. Tokens ofthe inventive subject matter remain valid for only a finite duration oftime (e.g., 1-5, 5-10, 10-15, 15-20, 20-30, 30-40, 40-50, 50-60, 60-90,90-120, and 120-150 seconds), where the duration of time is sufficientlylong for a client to successfully connect to one of the servers listedin the connect token. 30 seconds from time of creation of a connecttoken, for example, should be sufficient time for a client receiving theconnect token to use that connect token to connect to a server.

In circumstances where many discrete connection requests are sent to aserver (as in the example above), a set of servers are passed to theclient in the connection token so that even if the web backend sees thata server has a free slot for a client to connect, it could be the casethat a different client has already connected to that server and filledthat free slot by the time the client has attempted to connect. Thus,passing a set of servers to the client to attempt to connect toalleviates the issue of missing an open slot and failing to connect toany server at all.

Once a client has a connect token, the client attempts to connect to theset of servers as seen in FIG. 4. The client passes the connect tokenover UDP to establish the connection. In embodiments of the inventivesubject matter, servers will only allow clients to connect that havefirst requested a connect token. This process is depicted in FIG. 5.

Servers (e.g., dedicated server instances) can be machines running indata centers or in the cloud. In some embodiments, the connectionmeasures described above ensures that each client that connects isactually, for example, a real, paying customer, or at least has beenrate limited to ensure connection to only one server at a time. Oneadvantage of the inventive subject matter is that servers do not need toimplement any logic other than a token check (e.g., is the token validfor the server's IP address? is the token expired?). If the token isvalid, the server accepts the client's connection.

It is contemplated that servers and the web backend of the inventivesubject matter share a private key. The “private key” is a randomlygenerated key (e.g., a random string of characters) that is known toboth the web backend and the dedicated server instances. The private keymust not be known by the client, or the security model breaks down, andthe client would be able to generate, decrypt and read connect tokens.This security model relies on the private key being private between thededicated servers and the web backend.

In some embodiments of the inventive subject, the web backend and theservers do not share a private key. For example, each server can have aprivate and public key pair, and the web backend can have its ownprivate and public key pair. This allows the web server to generateconnect tokens encrypted and signed with the web backend private key,and the public key of the server that connect token corresponds to. Thisadds additional security. For example, if one server is compromised, itdoesn't compromise the whole system based around a shared private key,and connect tokens may only be decrypted by the server they weregenerated for.

An advantage of methods of the inventive subject matter is that effortsat rate limiting (e.g., to prevent DDoS attacks) can be accomplishedusing traditional web server techniques (e.g., on the web backend),rather than having to run logic on each server (e.g., dedicated serverinstance) independently, because the only way to connect to the serversis to get a connect token (that, for example, exists only for a durationof time) from the web backend first.

As mentioned above, a client receives the connect token which bringswith it a set of server IP addresses that the client can attempt toconnect to (e.g., in a particular order). While it is contemplated thatthe set of server IP addresses could include only a single server IPaddress, in some embodiments, the set includes multiple server IPaddresses in case the first server is filled by the time the clientattempts to connect to it. In an embodiment where the connect token isencrypted and signed with asymmetric encryption primitives (e.g.,private/public key pairs), this set of server IP addresses is no longerrequired because the connect token may only be decrypted by the serverit was generated for.

When a client is connecting to a server according to the inventivesubject matter, the client sends a connection request packet repeatedlyover UDP, as seen in Step 1 of FIG. 5. This packet can contain all orsome subset of: the private connect token data, additional data for theAEAD such as the version information, protocol ID (e.g., a unique 64-bitnumber), expiration timestamp for the connect token, and the sequencenumber for the AEAD primitive.

When the server receives a connection request over UDP, it checks thatthe contents of the packet are valid using, for example, the AEADprimitive. If any of the public data in the connection request packet ismodified, the signature check will fail. This prevents clients frommodifying, for example, the expiration timestamp for a connect token,while also reducing rejection time for expired tokens.

If the private connect token data and the corresponding associated datafor the AEAD included in the connection request packet are valid, theprivate connect token data included in the connection request packet isdecrypted. As mentioned above, the private connect token data contains alist of dedicated servers (e.g., server IP addresses) that the connecttoken is valid for, which stops malicious clients going wide with oneconnect token and using it to connect to all available dedicatedservers.

In some embodiments, the server also checks if the connect token hasalready been used by searching a short history of connect tokenauthentication codes (e.g., keyed-hash message authentication codes(HMACs)), and ignores the connection request if a match is found. Thisprevents one connect token from being used to connect multiple clientsto the same server.

The server can also enforce a variety of connection rules. For example,only one client with a given IP address could be allowed to be connectedat any time, and only one client by unique client ID (e.g., a 64-bitinteger that uniquely identifies a client that has been authenticated bythe web backend) could be allowed to be connected at any time.

If the connect token has not expired, it decrypts successfully, thededicated server's public IP is in the list of server addresses (e.g.,in an embodiment that uses a shared private key), and any other checkspass, the dedicated server sets up a mapping between the client IPaddress and the encryption keys contained in the private connect tokendata. All packets exchanged between the client and server from thispoint are encrypted using these keys. This encryption mapping expires ifno UDP packets are received from the client IP address for a duration oftime (e.g., 5 seconds).

Next, the server checks if there is room for the client to connect tothe server. Each server supports some maximum number of clients (e.g., a64-player game has 64 slots for clients to connect to). If the server isfull, it responds with a connection request denied packet, as shown inStep 2 of FIG. 5. This lets the client know to move on to the nextserver in the list of servers contained in the connect token when aserver is full. If there is room for the client to connect to theserver, the server stores the address and HMAC for the connect token forthat client as a potential client. The server then responds with aconnection challenge packet, as shown in Step 2 of FIG. 5, whichcontains a challenge token that contains some data relevant to thatpotential client connection encrypted with a random key rolled when theserver is started. This avoids storing large blocks of data on theserver for each potential client, by storing this data in the encryptedchallenge token data instead.

The key randomization for encrypted challenge tokens ensures there isnot a security problem when the same sequence number is used to encryptchallenge tokens across multiple servers. This is necessary because theservers do not coordinate with each other. Moreover, the connectionchallenge packet is significantly smaller than the connection requestpacket by design. This eliminates the possibility of the protocol beingused as part of a DDoS amplification attack.

The client receives the connection challenge packet over UDP andswitches to a state where it sends connection response packets to theserver, as shown in Step 3 of FIG. 5. Connection response packetsreflect a challenge token back to a server, establishing that a clientcan receive packets on a source IP address it claims to be sendingpackets from. This stops clients with spoofed packet source addressesfrom connecting to the server.

When the server receives a connection response packet it looks for amatching pending client entry, and if one exists, it searches once againfor a free slot for the client to connect to, as shown in Step 3 of FIG.5. After a server receives a connection response packet and assigns theclient to a slot, the server sets that client slot into an “unconfirmed”state, even though that client is considered logically connected fromthe server point of view. If no free slot exists, it replies with aconnection request denied packet since there may have been a slot freewhen the connection request was first received that is no longeravailable. If the connection response packet does not correspond to anyvalid pending client entry on the server, it is ignored.

In some embodiments, the server assigns the client to a free slot andreplies with a connection keep-alive packet, which tells the clientwhich slot it was assigned on the server (e.g., a client index). Inmultiplayer games, for example, a client index is typically used toidentify clients connected to a server. For example, clients 0, 1, 2,and 3 in a 4-player game correspond to players 1, 2, 3 and 4.

Once a server assigns a client to a free slot, the server considers theclient connected and can send connection payload packets to that clientover a client-server connection, as shown in Step 4 of FIG. 5. Thesepackets wrap game specific data and are delivered unreliable-ordered.But since the client needs to first receive a connection keep-alivebefore it knows its client index and can consider itself to be fullyconnected, the server tracks on a per-client slot basis whether thatclient is confirmed.

A connection confirmed flag per-client is initially set to “false,” andit flips true once the server has received a connection keep-alivepacket or connection payload packetfrom that client. In someembodiments, until a client is confirmed, each time a connection payloadpacket is sent from a server to a client, the connection payload packetis preceded by a connection keep-alive packet as seen in FIG. 6. Thisensures the client is statistically likely to know its client index(which is included in connection keep-alive packets) and be fullyconnected prior to receiving the first connection payload packet sentfrom the server (as seen in FIG. 7), minimizing the number of connectionestablishment round-trips.

Below follows an example of packet exchange leading to clientconfirmation. (1) A server marks a client as fully connected whenreceiving valid connection response packet. (2) The server immediatelysends back a connection keep-alive packet in response. (3) The serversets the connection confirmed flag for that client to false. (4) Gamecode running on the server may now send connection payload packets atany rate. But if the server does not send connection payload packets forsome duration of time (e.g., 0.1 s), the server generates and sendsconnection keep-alive packets at some rate (e.g., 5-10 Hz, 10-15 Hz,15-20 Hz, 20-30 Hz, 30-40 Hz, 40-50 Hz, 50-60 Hz, 60-120 Hz or avariable rate within one, or some combination of, those ranges) in theabsence of connection payload packets being sent. For each connectionpayload packet the server sends under these conditions, the server alsosends a connection keep-alive packet in front of it for non-confirmedclients (as shown in, for example, FIG. 6). (5) The client receives theconnection keep-alive packet, marks itself as fully connected, andstores the client index contained in the connection keep alive packet.(6) The client may now send connection payload packets back to theserver at any rate, but if no connection payload packets are sent for aduration of time (e.g., 0.1 s), the client automatically generatesconnection keep-alive packets to send to the server at some rate (e.g.,5-10 Hz, 10-15 Hz, 15-20 Hz, 20-30 Hz, 30-40 Hz, 40-50 Hz, 50-60 Hz,60-120 Hz or a variable rate within one, or some combination of, thoseranges) in the absence of connection payload packets being sent. (7) Theserver receives a connection keep-alive or a connection payload packetfrom the client. (8) the server marks that client as “confirmed.” (9)The server ceases to send a connection keep-alive packet in front ofeach connection payload packet sent to the client. And finally (10),with both client and server fully connected and confirmed, bidirectionalconnection payload packets can be exchanged at whatever rate anapplication (e.g., a game) requires. On both the server side and theclient side, if no connection payload packets are sent for a duration oftime (e.g., 0.1 s), the side (i.e., client or server) that has not senta connection payload packet will then generate and send connectionkeep-alive packets at some rate (e.g., 5-10 Hz, 10-15 Hz, 15-20 Hz,20-30 Hz, 30-40 Hz, 40-50 Hz, 50-60 Hz, 60-120 Hz or a variable ratewithin one, or some combination of, those ranges) in the absence ofconnection payload packets being sent.

After establishing a client-server connection, UDP packets can beexchanged bidirectionally. Typical game protocols, for example, sendplayer inputs from a client to a server at a high rate (e.g., 60 Hz) andworld-state information from the server to client at a lower rate (e.g.,20 Hz, but in some instances 30 Hz, 40 Hz, or 60 Hz).

In some embodiments, if the server or client fail to exchange a steadystream of packets, connection keep-alive packets are automaticallygenerated (by one or both of the server and client) to prevent theconnection from timing out. A timeout occurs if no packets are receivedfrom either side of the connection for an amount of time (e.g., 5-10seconds).

If either side of the connection wishes to cleanly disconnect, severalconnection disconnect packets are transmitted redundantly, increasingthe chance that at least one of the connection disconnect packetsreaches its destination even under packet loss. This ensures a clean andrapid disconnection (e.g., without waiting for a time out). In onedisconnection example shown in FIG. 8a , a client initiates a cleandisconnect, where the client sends disconnect packets to the server sothat the server does not need to wait for a timeout to occur. In anotherdisconnection example shown in FIG. 8b , a server initiates a cleandisconnect, where the server sends disconnect packets to the client, sothe client does not need to wait for a timeout.

An implementation of the inventive subject matter described in thisapplication based around shared private key has been developed andentitled netcode.io. The following discussion is related to thenetcode.io implementation. Any reference to netcode.io is a reference tothe inventive subject matter. Inventive features from this point forwardcan be incorporated into inventive features described above in anymanner.

Netcode.io is a binary protocol. All data is written in little-endianbyte order unless otherwise specified. This applies not only to tokenand packet data, but also to sequence numbers converted to byte arraynonce values, and associated data passed in to AEAD encryptionprimitives.

There are three main components in a netcode.io-based architecture: (1)the web backend, (2) dedicated servers, and (3) clients. These entitiesare shown in at least FIGS. 1, 2, and 4. The web backend can be atypical web server (e.g., nginx), which authenticates clients andprovides a REST API. The term “web server” can refer to any computersystem that processes requests via HTTP. It can refer to an entiresystem, or specifically to software that accepts and supervises HTTPrequests.

Clients are endpoints running the netcode.io protocol that can connectto dedicated server instances. Dedicated servers are instances of theserver-side portion of a game or application running in data centers ora cloud.

For a client to connect to a dedicated server using netcode.io, asequence of operations must occur: (1) a client authenticates with theweb backend, as shown in FIG. 1; (2) the authenticated client requeststo play a game via REST call to the web backend, as shown in FIG. 2; (3)the web backend generates a connect token, shown in FIG. 2, and returnsit to that client over HTTPS; (4) the client uses the connect token, thecontents of which are shown in FIG. 3, to establish a connection with adedicated server over UDP; (5) the dedicated server runs logic to ensurethat only clients with a valid connect token can connect to it; and (6)once a connection is established, the client and server exchangeencrypted and signed UDP packets, as shown in FIG. 5.

A connect token ensures that only authenticated clients can connect todedicated servers. As shown in FIG. 3, the connect token has two parts:public and private. The private data is encrypted and signed with aprivate key shared between the web backend and dedicated serverinstances. Portions of the public data are signed with the sharedprivate using an encryption primitive called AEAD (authenticatedencryption with associated data), such that they may be read, but notmodified without breaking the signature. Connect tokens are variablysized, but for simplicity they are written to a fixed size buffer of1024 bytes. Unused bytes are zero-padded.

Encryption of the private connect token data in the netcode.ioimplementation is performed with the libsodium AEAD primitivecrypto_aead_chacha20poly1305 ietf_encrypt with binary data representingversion info (e.g., “NETCODE 1.00” ASCII with null terminator), protocolID (e.g., a 64-bit value unique to a game/application), and expirationtimestamp (e.g., a 64-bit Unix timestamp defining when the connect tokenexpires) included as the associated data. The nonce (e.g., an arbitrarynumber used only once in a cryptographic communication) used forencryption is a 64-bit sequence number that starts at zero and increaseswith each connect token generated. The sequence number is extended bypadding high bits with zero to create a 96-bit nonce.

Encryption is performed on the first 1008 bytes in the buffer, leavingthe last 16 bytes to store the HMAC. Thus, the encrypted portion of theprivate connect token uses 1008 bytes while the HMAC of the encryptedprivate connect token uses 16 bytes for a total of 1024 bytes. Afterencryption, this data is referred to as the encrypted private connecttoken data.

Together the public data and private data form a connect token. Thus, aconnect token includes: (1) version info (13 bytes) (e.g., “NETCODE1.00” ASCII with null terminator); (2) a protocol ID (uint64) (e.g., a64-bit value unique to a game/application); (3) a timestamp indicatingwhen the connect token was created (uint64) (e.g., a 64-bit Unixtimestamp indicating when a connect token was created); (4) anexpiration timestamp (uint64) (e.g., a 64-bit Unix timestamp when thisconnect token expires); (5) a connect token sequence (uint64); (6)encrypted private connect token data (1024 bytes); (7) dedicated serveraddresses and ports (uint32) (e.g., between 1 and 32 server addressesand ports); (8) a client to server key (32 bytes); (9) a server toclient key (32 bytes); and (10) a timeout time (uint32) (e.g., a numberof seconds with no packets before a client times out, including: 1-5seconds, 5-10 seconds, and 10-15 seconds). Any unused bytes in a connecttoken, up to 2048 bytes, are set to zeroes.

Challenge tokens, shown in FIG. 9, are used to stop clients with spoofedIP packet source addresses from connecting to dedicated servers. Beforeencryption, challenge tokens include: (1) a client ID (uint64) and (2)user data (256 bytes). Any unused bytes in a challenge token, up to 300bytes, are set to zeroes.

Challenge token data is encrypted using, for example, the libsodium AEADprimitive crypto_aead_chacha20poly1305_ietf_encrypt with no associateddata, a random key generated when the dedicated server starts, and asequence number that starts at zero and increases with each challengetoken generated). The sequence number is extended by padding high bitswith zero to create a 96-bit nonce.

Encryption is performed on the first 284 bytes of the challenge token,leaving the last 16 bytes store the HMAC of the encrypted buffer, whichis referred to as the encrypted challenge token data.

The netcode.io implementation uses the following packets: (1) aconnection request packet; (2) a connection denied packet; (3) aconnection challenge packet; (4) a connection response packet; (5) aconnection keep alive packet; (6) a connection payload packet; and (7) aconnection disconnect packet.

Connection request packets, shown in FIG. 10, are not encrypted, and inthe netcode.io implementation they include several components: (1) 0(uint8) (a prefix byte of zero); (2) version info (e.g., 13 bytescontaining version information) (e.g., “NETCODE 1.00” ASCII with nullterminator); (3) a protocol ID (8 bytes); (4) a connect token expirationtimestamp (8 bytes); (5) a connect token sequence number (8 bytes); (6)encrypted private connect token data (1024 bytes). All other packettypes are encrypted.

Before encryption, packets that are to be encrypted (e.g., connectiondenied packets, connection challenge packets, connection responsepackets, connection keep alive packets, connection payload packets, andconnection disconnect packets) have the following format: (1) prefixbyte (uint8) (e.g., a non-zero prefix byte where the low 4 bits of theprefix byte contain the packet type and high 4 bits contain the numberof bytes for the sequence number in the range of 1-8); (2) sequencenumber (e.g., variable length 1-8 bytes that is encoded by omitting highzero bytes); (3) per-packet type data (e.g., variable length accordingto packet type).

To give an example of a sequence number that is encoded by omitting highzero bytes, a sequence number of 1000 is 0x000003E8 and requires onlytwo bytes to send its value. Therefore, the high 4 bits of the prefixbyte are set to 2 and the sequence data written to the packet is 0xE8,0x03. The sequence number bytes are reversed when written to the packet.

As mentioned above, after the sequence number comes the per-packet typedata. Per-packet type data can include: (1) a connection denied packet(e.g., no data); (2) a connection challenge packet (e.g., a challengetoken sequence (uint64) and encrypted challenge token data (300 bytes));(3) a connection response packet (e.g., a challenge token sequence(uint64) and encrypted challenge token data (300 bytes)); (4) aconnection keep-alive packet (e.g., a client index (uint32) and maxclients (uint32)); (5) a connection payload packet (e.g., payload data(1 to 1200 bytes)); and (6) a connection disconnect packet (e.g., nodata).

The per-packet type data is encrypted. Encryption in the netcode.ioimplementation is accomplished using the libsodium AEAD primitivecrypto_aead_chacha20poly1305 ietf_encrypt with the following binary dataas the associated data: (1) version info (13 bytes) (e.g., “NETCODE1.00” ASCII with null terminator); (2) a protocol ID (uint64) (e.g.,64-bit value unique to a game or application; and (3) a prefix byte(uint8) (e.g., a prefix byte in packet that stops an attacker frommodifying the packet type).

The packet sequence number is extended by padding high bits with zero tocreate a 96-bit nonce. Packets sent from client to server are encryptedwith the client to server key in the connect token. Packets sent fromserver to client are encrypted using the server to client key in theconnect token for that client.

Post encryption, encrypted packet types (e.g., all packets except theconnection request packets) have the following format: (1) a prefix byte(uint8) (e.g., a non-zero prefix byte); (2) a sequence number (e.g., anumber having a variable length between 1-8 bytes); (3) encryptedper-packet type data, which has variable length according to packettype; and (4) an HMAC of encrypted per-packet type data (e.g., 16bytes).

Reading an encrypted packet in the netcode.io implementation requirescompleting several steps in sequence, as shown in FIG. 11. First, if thepacket size is less than 18 bytes then it is too small to possibly bevalid, and the packet is ignored. Next, if the low 4 bits of the prefixbyte are greater than or equal to 7, the packet type is invalid, and thepacket is ignored. Next, the server ignores connection challengepackets. Next, the client ignores connection request packets andconnection response packets. Next, if the high 4 bits of the prefix byte(e.g., sequence bytes) are outside the range of 1-8, the packet isignored. Next, if the packet size is less than 1+sequence bytes+16, thepacket is invalid and the packet is ignored. Next, if the packet typefails a replay protection test (discussed in more detail below), thepacket is ignored. Next, if the per-packet type data fails to decrypt,the packet is ignored. Next, if the per-packet type data size does notmatch the expected size for the packet type, the packet is ignored.Expected sizes for each type of packet are as follows: 0 bytes for aconnection denied packet, 308 bytes for a connection challenge packet,308 bytes for a connection response packet 8 bytes for a connectionkeep-alive packet, from 1 to 1200 bytes for a connection payload packet,and 0 bytes for a connection disconnect packet. Finally, if all theabove checks pass, the packet is processed.

Replay protection, mentioned briefly in the preceding paragraph, stopsan attacker from recording a valid packet and replaying it back later tobreak the protocol. To enable replay protection, netcode.io implementsseveral measures. For example, encrypted packets are sent with 64-bitsequence numbers that start at zero and increase with each packet sent.Sequence numbers can be included in the packet header and can be read bythe receiver of a packet prior to decryption. Moreover, sequence numberscan be used as the nonce for packet encryption, so any modification tothe sequence number fails the encryption signature check.

Replay protection, as shown in FIG. 12, operates as follows. First,packets are received and stored in a replay buffer having a set replaybuffer size. The replay buffer size determines a quantity of packetsthat can be stored in the replay buffer (e.g., 64-128, 128-256, 256-512,512-1028 packets). Replay buffer size is implementation specific. Insome embodiments, a few seconds worth of packets at a typical send rate(20-60 Hz) is supported. For example, a replay buffer size of 256entries per-client should be sufficient for most applications. Eachpacket received has an associated sequence number. Any packet having asequence number that is older than the most recent sequence numberreceived (e.g., received with a packet), minus the replay buffer size,is discarded on the receiver side.

For example, if a replay buffer size is 100, and the most recent packetreceived has a sequence number of 600, a packet having a sequence numberof 499 or less (i.e., 1 less than 600 minus 100) would be discarded.When a new packet arrives that has a more recent sequence number thanthe previously most recent sequence number received, the sequence numberassociated with the new packet is updated on the receiver side and thenew packet is accepted. If a packet arrives that is within replay buffersize of the most recent sequence number, it is accepted only if itssequence number has not already been received. If a packet is receivedhaving a sequence number that has already been received, that packet isignored.

Replay protection can be applied to the following packet types on boththe client-side and the server-side: (1) connection keep alive packets,(2) connection payload packets, and (3) connection disconnect packets.

In the netcode.io implementation, the client can indicate the followingstates (in the format of “state (state code),” where negative statecodes indicate errors and a zero state code indicates disconnection):connect token expired (−6); invalid connect token (−5); connection timedout (−4); connection response timed out (−3); connection request timedout (−2); connection denied (−1); disconnected (0); sending connectionrequest (1); sending connection response (2); connected (3).

When a client wants to connect to a server, it requests a connect token(FIG. 3) from the web backend, as shown in FIG. 2. Once the client hasobtained a connect token, its goal is to establish a connection to oneof the server addresses in the connect token, as shown in FIG. 4. Tobegin this process, it transitions to sending connection request withthe first server address in the connect token.

Before doing this, the client verifies connect token validity, as shownin FIG. 13. For example, if the number of server addresses in theconnect token are outside of the range of 1-32, if any address typevalues in the connect token are outside of the range of 0-1, or if acreation timestamp is more recent than an expiration timestamp, then theclient transitions to the invalid connect token state.

As shown in Step 1 of FIG. 5, while in the sending connection requeststate, the client sends connection request packets to the server at somerate (e.g., 5-10 Hz, 10-15 Hz, 15-20 Hz, 20-30 Hz, 30-40 Hz, 40-50 Hz,50-60 Hz, 60-120 Hz or a variable rate within one, or some combinationof, those ranges). When the client receives a connection challengepacketfrom the server as shown in Step 2 of FIG. 5, it stores thechallenge token data and transitions to the sending challenge responsestate.

All other transitions from the sending connection request state arefailure cases. In these failure cases, the client attempts to connect tothe next server address in the connect token (e.g., transitioning to thesending connection request state with the next server address in theconnect token, as illustrated by FIG. 2). Alternatively, if there are noadditional server addresses to connect to, the client transitions to theappropriate error state as described below.

If a client receives a connection request denied packet while in thesending connection request state as shown in FIG. 14, the clienttransitions to the connection denied state. If a client receives neithera connection challenge packet nor a connection denied packet within thetimeout period specified in the connect token as shown in FIG. 15, theclient transitions to connection request timed out.

While a client is in the sending challenge response state, the clientsends challenge response packets to the server at some rate (e.g., 5-10Hz, 10-15 Hz, 15-20 Hz, 20-30 Hz, 30-40 Hz, 40-50 Hz, 50-60 Hz, 60-120Hz or a variable rate within one, or some combination of, those ranges).When the client receives a connection keep-alive packet from the server,it stores the client index and maximum number of clients in the packet(e.g., the “connected” state in the client state machine), andtransitions to connected. Any connection payload packets received priorto the client transitioning to the connected state are discarded.

If the connect token expires (e.g., if the entire client connectionprocess-which can span across multiple server addresses-takes longenough that the connect token expires before successfully connecting toa server), the client transitions to the connect token expired state.The length of time until expiration can be determined by subtracting theconnect token's creation timestamp from the connect token's expirationtimestamp.

While in the connected state, the client buffers connection payloadpackets received from the server so their payload data can be deliveredto the client application as netcode.io packets. Also, while in theconnected state, the client application can send connection payloadpackets to the server. In the absence of connection payload packets sentby a client, the client generates and sends connection keep-alivepackets to the server at some rate (e.g., 5-10 Hz, 10-15 Hz, 15-20 Hz,20-30 Hz, 30-40 Hz, 40-50 Hz, 50-60 Hz, 60-120 Hz or a variable ratewithin one, or some combination of, those ranges). If neither connectionpayload packets nor connection keep-alive packets are received from theserver within the timeout period specified in the connect token, theclient transitions to the connection timed out state.

While in the connected state, if a client receives a connectiondisconnect packet from the server, the client transitions to thedisconnected state. If a client wants to disconnect from a server, theclient sends several (e.g., 1-10) redundant connection disconnectpackets before transitioning to the disconnected state.

The preceding discussion related to the netcode.io implementationrelates primarily to the client-side of the inventive subject matter.The following discussion is related primarily to the server-side of theinventive subject matter.

To begin, the dedicated server (which is interchangeably referred to as“server,” “dedicated server,” or “dedicated server instance”) must be ona publicly accessible IP address and port. The server manages a set of nclient slots, where each slot from ranging from 0 to n−1 represents roomfor one connected client. The maximum number of client slots per serveris implementation specific. Typical uses cases are expected in the rangeof 2 to 64 but support for up to 256 clients per server is contemplated.The upper bound for client slots on a server is limited by theefficiency of a particular implementation of the protocol.

Dedicated servers in the netcode.io implementation are required tofollow strict rules when processing connection requests. First, clientsmust have a valid connect token to connect to a server. Second, a serverresponds to a client only when absolutely necessary. Third, serversignore any malformed request as soon as possible, with a minimum amountof work. And finally, servers ensure response packets (e.g., responsepackets of any type) are smaller than request packets to avoid DDoSamplification (e.g., where request packets and response packets are inpairs, it is required that response packets are smaller than theircorresponding request packets).

When a server receives a connection request packet from a client itcontains the following data: (1) a prefix byte of zero (e.g., uint8);(2) version information (e.g., 13 bytes containing, “‘NETCODE 1.00’ASCII with null terminator”); (4) protocol ID (e.g., 8 bytes); connecttoken expire timestamp (e.g., 8 bytes); (5) connect token sequencenumber (e.g., 8 bytes); and (6) encrypted private connect token data(e.g., 1024 bytes).

Connection request packets are not encrypted. Only a dedicated serverinstance and the web backend can read encrypted private connect tokendata, because it is encrypted with a private key shared between thededicated server instance and the web backend. In the netcode.ioimplementation, important contents of a connection request packet, forexample, version info, protocol ID, and connect token expirationtimestamp are protected by the AEAD construct, and thus cannot bemodified without failing a signature check.

When processing a connection request packet, a server undertakes asequence of steps. In the netcode.io implementation, the steps describedin the following paragraph a preferably completed in order, but it iscontemplated that the steps can be completed in a different order, and,in some embodiments, steps can be skipped. Steps 1 through 10 areillustrated in FIG. 16.

First, if the connection request packet is not the expected size (e.g.,1062 bytes) the server ignores the packet. Second, if the version infoin the connection request packet doesn't match “NETCODE 1.00” (13 bytes,with null terminator), the server ignores the packet. Third, if theprotocol ID in the connection request packet doesn't match the expectedprotocol ID of the dedicated server, the server ignores the packet.Fourth, if the connect token expiration timestamp in the connectionrequest packet is less than or equal to the current timestamp, theserver ignores the packet. Fifth, if the encrypted private connect tokendata in the connection request packet doesn't decrypt with the privatekey using associated data constructed from a combination of some or allof version information, protocol ID, and expiration timestamp, theserver ignores the packet.

Sixth, if the decrypted private connect token in the connection requestpacket fails to be read for any reason, the server ignores the packet.For example, the server ignores the connection request packet if theprivate connect token has one or more server addressed outside of theexpected range of 1 to 32, or if it has an address type value outside ofrange 0 to 1. Seventh, if the dedicated server public address is not inthe list of server addresses in the private connect token in theconnection request packet, the server ignores the packet. Eighth, if aclient from the connection request packets IP source address and port isalready connected, ignore the packet. Ninth, if a client having a clientID contained in the private connect token data of the connection requestpacket is already connected, the server ignores the packet. Tenth, ifthe connect token in the connection request packet has already been usedby a different packet source IP address and port, the server ignores thepacket. Otherwise, the server adds the private connect token HMAC andpacket source IP address and port to the history of connect tokensalready used.

Eleventh, if no client slots are available on the server (indicating theserver is full), the server responds with a connection denied packet.Twelfth, the server adds an encryption mapping for the packet source IPaddress and port so that packets read from that address and port aredecrypted with the client to server key in the private connect token,and packets sent to that address and port are encrypted with the serverto client key in the private connect token. This encryption mappingexpires after some number of seconds where no packets being sent to orreceived from that address and port (e.g., after timing out, where atimeout can occur after, for example, 1-5 s, 5-10 s, or 10-20 s), or ifa client fails to establish a connection with the server before timingout.

The next steps—beginning with thirteen—are shown in FIG. 17, and are acontinuation of the preceding steps. Thirteenth, if for some reasonencryption mapping cannot be added, the server ignores the packet. Andfinally, in the absence of any of the preceding conditions being met,the server responds with a connection challenge packet and incrementsthe connection challenge sequence number.

Next, connection response packets must be processed. When the clientreceives a connection challenge packet from the server, the clientresponds with a connection response packet (as shown in FIG. 5), which,in some embodiments, contains: (1) a prefix byte (uint8) (e.g., anon-zero prefix byte: ((num_sequence_bytes<<4)|packet_type)); (2) asequence number (e.g., having a variable length of 1-8 bytes); (3) achallenge token sequence (uint64); (4) an encrypted challenge token data(e.g., 360 bytes).

It is then contemplated that a server can take several steps whenprocessing a connection response packet, as shown in FIG. 18. In someembodiments, a server completes the following steps, in order. It iscontemplated that the server can cease to carry out steps: (1) if theencrypted challenge token data fails to decrypt, the server ignores thepacket; (2) if a client from the packet source address and port isalready connected, the server ignores the packet; (3) if a client withthe client ID contained in the encrypted challenge token data is alreadyconnected, the server ignores the packet; (4) if no client slots areavailable (e.g., the server is full), the server responds with aconnection denied packet, (5) the server assigns the packet IP address,port, and client ID to a free client slot and marks that client asconnected; (6) the server copies the user data from the challenge tokeninto a client slot so the user data is accessible to a serverapplication; (7) the server sets the confirmed flag for that client slotto false; (8) finally, the server responds with a connection keep-alivepacket.

Once a client is assigned to a slot on the server, it is consideredlogically connected. The index of the slot is used to identify clientson the server and is called the client index. Packets (e.g., connectionkeep-alive packets, connection payload packets, and connectiondisconnect packets) received by the server from that client's addressand port are mapped to that client index and processed in the context ofthat client.

To ensure delivery of payload data from client to server as netcode.iopackets, the server buffers connection payload packets received fromconnected clients. In some embodiments, the server (e.g., a serverapplication) can send connection payload packets to connected clients.

In the absence of connection payload packets sent to a client, theserver generates and sends connection keep-alive packets to that clientat some rate (e.g., 5-10 Hz, 10-15 Hz, 15-20 Hz, 20-30 Hz, 30-40 Hz,40-50 Hz, 50-60 Hz, 60-120 Hz or a variable rate within one, or somecombination of, those ranges).

While the confirmed flag for a client slot is false, each connectionpayload packet sent to that client is preceded by (e.g., prefixed with)a connection keep-alive packet. This communicates the client index andthe max clients to that client, which it needs to transition to a fullyconnected state.

In some instances, a server can receive a connection payload packet or aconnection keep-alive packet from an unconfirmed client. When thisoccurs, the server sets the confirmed flag for that client slot to trueand ceases prefixing connection payload packets with connectionkeep-alive packets.

For a server to disconnect a client, the server sends a number ofredundant connection disconnect packets to that client before resettingthat client's client slot. If neither a connection payload packet nor aconnection keep-alive packet is received from a client within timeoutperiod specified in a connect token, or if the server receives aconnection disconnect packet from a client, then the client slot isreset and becomes available for other clients to connect to.Disconnection is illustrated in FIG. 8a -8 b.

The inventor contemplates that the netcode.io implementation of theinventive subject matter can incorporate asymmetric cryptography asdiscussed earlier in this application where a shared private key isreplaced by a private/public key pair per-server, and a private/publickey pair on the web backend, and encrypting connect tokens for specificservers using the private key of the web backend and the public key ofthat server.

The inventive subject matter described in this application improves thefunctioning of client-server networking communications by reducingcomplexity, increasing security, and enabling an entire new generationof web-based game development.

Specific methods of network communication using UDP have been disclosed.It should be apparent, however, to those skilled in the art that manymore modifications besides those already described are possible withoutdeparting from the inventive concepts in this application. The inventivesubject matter, therefore, is not to be restricted except in the spiritof the disclosure. Moreover, in interpreting the disclosure all termsshould be interpreted in the broadest possible manner consistent withthe context. In particular, the terms “comprises” and “comprising”should be interpreted as referring to the elements, components, or stepsin a non-exclusive manner, indicating that the referenced elements,components, or steps can be present, or utilized, or combined with otherelements, components, or steps that are not expressly referenced.

What is claimed is:
 1. A method of creating a network connection betweena client and a server to facilitate multiplayer gaming, comprising:requesting a connect token by sending a call to a web backend, whereinthe connect token comprises public data and private data; receiving theconnect token from the web backend via a secure channel; sending, to theserver, a connection request packet comprising portions of the privatedata and the public data; receiving, from the server, a connectionchallenge packet; sending, to the server, a connection response packet;establishing the network connection with the server.
 2. The method ofclaim 1, wherein the private data is encrypted and signed by a sharedprivate key, and portions of the public data are signed by the sharedprivate key.
 3. The method of claim 1, wherein the private data isencrypted and signed by a web backend private key and a server publickey, and portions of the public data are signed by the web backendprivate key and by the server public key.
 4. The method of claim 1,wherein the public data comprises at least one of: (1) encryption keysfor payload packets, and (2) a list of server addresses.
 5. The methodof claim 1, wherein the connection challenge packet comprises achallenge token, wherein the challenge token: (1) comprises datarelevant to the UDP network connection and (2) is encrypted with arandom key rolled when the server is started.
 6. The method of claim 1,wherein the connection challenge packet is smaller than the connectionrequest packet to eliminate a possibility of a DDoS attack.
 7. Themethod of claim 1, further comprising the step of receiving connectionpayload packets after establishing the network connection with theserver.